class LiczbaException extends Exception {
	public LiczbaException() {
		super();
	}
	
	public LiczbaException(String message) {
		super(message);
	}
}

//##########################

public class Liczba {
	
	public int number;
	public char[] signs = {'a', 'b', 'c', 'd', 'e', 'f'};
	
	//***************************
	
	public Liczba() {
		number = 0;
	}
	
	//***************************
	
	public Liczba(int number) throws LiczbaException {
		this.number = number;
		checkNumber();
	}
	
	//***************************
	
	public String getNumberWithBase(int base) throws LiczbaException {
		
		checkNumber();
		
		if(base < 2 || base > 16) {
			throw new LiczbaException("Base should be integer value from range <2,16>.");
		}

		return Integer.toString(number, base);
	}
	
	//*************************
	/**Additional class for number conversion
	 */
	public String convert(int base) throws LiczbaException {
		checkNumber();
		
		if(base < 2 || base > 16) {
			throw new LiczbaException("Base should be integer value from range <2,16>.");
		}
		
		String answer = new String("");
		int max = 1;
		int maxBase = 0;
		int helpNumber = 0;
		helpNumber += number;
		
		while(helpNumber >= max * base)
		{
			max *= base;
			maxBase += 1;
		}
		
		while(helpNumber != 0) {
			int numberToEnter = (int)(helpNumber / max);
			if(numberToEnter > 9) {
				answer += signs[numberToEnter - 10];
			}
			else {
				answer += Integer.toString(numberToEnter);
			}
				
			helpNumber -= max * numberToEnter;
			
			max /= base;
			maxBase -= 1;
			
			while(max > helpNumber) {
				answer += '0';
				max /= base;
				maxBase -= 1;
			}
			System.out.println(answer );
		}
		return answer;
	}
	
	//*************************
	
	protected void checkNumber() throws LiczbaException{
		if(number < 0) {
			number = 0;
			throw new LiczbaException("Number should be natural.");
		}
	}
}